using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Presenters;
using Dominio;


public partial class myAccountPage : AbstractView
{
    private MyAccountPresenter presenter;
    private Tester tester;
    public myAccountPage()
    {
        presenter = new MyAccountPresenter();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        this.LogedIn();
        User user = (User)Session["user"];

        if (user.Role.isAdmin(user))
        {
            tester = (Tester)presenter.getUserById(int.Parse(Request.QueryString.Get("selectUser")));
            this.statuslbl.Visible = true;
            this.guardarlink.Visible = true;
            this.statusdrop.Visible = true;
            this.statusdrop.SelectedValue = tester.State;
            this.nameinfo.Text = tester.Name;
            this.lastnameinfo.Text = tester.LastName;
            this.countryinfo.Text = tester.Country;
            this.borninfo.Text = tester.Born.ToString();
            this.addressinfo.Text = tester.Address;
            this.cityinfo.Text = tester.City;
            this.mailinfo.Text = tester.Email;
            this.dniinfo.Text = tester.Dni.ToString();
        }
        else
        {
            this.nameinfo.Text = user.Name;
            this.lastnameinfo.Text = user.LastName;
            this.countryinfo.Text = user.Country;
            this.borninfo.Text = user.Born.ToString();
            this.addressinfo.Text = user.Address;
            this.cityinfo.Text = user.City;
            this.mailinfo.Text = user.Email;
            this.dniinfo.Text = user.Dni.ToString();
        }
        CompanyInformation.Visible = ((User)Session["user"]).Role.isTM(((User)Session["user"]));
    }
    protected void CompanyInformation_Click(object sender, EventArgs e)
    {
        Response.Redirect("CompanyInformation.aspx");
    }

    protected void guardarlink_Click(object sender, EventArgs e)
    {
        tester.State = statusdrop.SelectedValue;
        presenter.updateUser(tester);
    }
}
